package com.hs.mpdemo_01.controller;

import com.hs.mpdemo_01.service.FileUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @ClassName FileUploadController
 * @Description 文件上传接口
 */
@RestController
@RequestMapping("/upload")
public class FileUploadController {

    @Autowired
    FileUploadService service;

    @PostMapping
    public String uploadOneFile(@RequestBody MultipartFile file, HttpSession session) throws IOException {
        String path = service.uploadOneFile(file, session);
        return "path:"+path;
    }
}
